package static_;

public class ChildGame {
    public static void main(String[] args) {

        //int count = 0;
        Child c1 = new Child("白骨精");
         c1.join();
//        count++;

        Child c2 = new Child("狐狸精");
          c2.join();
//        count++;

        Child c3 = new Child("老鼠精");
          c3.join();
//        count++;

        System.out.println("共有" + Child.count + "个小孩加入游戏");
    }
}

class Child{//类
    private String name;
    //定义一个变量count,是一个类变量（静态变量）static 静态
    //该变量最大的特点就是会被Child类的所有的对象实例共享
    public static int count = 0;
    public Child(String name){
        this.name = name;

    }
    public void join(){
        System.out.println(name + "加入了游戏");
        count++;
    }

}
